package com.yunpay.config;

import org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

@Configuration
@ImportResource("classpath:spring/spring-all.xml")
public class Config {
	
	private String cache_host;
	private String cache_port;
	private String cache_maxActive;
	private String cache_maxIdle;
	private String cache_maxWait;
	private String cache_testOnBorrow;
	private String cache_password;
	private String cache_isMaster;
	
	private String slave_cache_host;
	private String slave_cache_port;
	private String slave_cache_maxActive;
	private String slave_cache_maxIdle;
	private String slave_cache_maxWait;
	private String slave_cache_testOnBorrow;
	private String slave_cache_password;
	private String slave_cache_isMaster;
	
	@Bean
	public BeanNameAutoProxyCreator beanNameAutoProxyCreator() {
	    BeanNameAutoProxyCreator beanNameAutoProxyCreator = new BeanNameAutoProxyCreator();
	    beanNameAutoProxyCreator.setBeanNames("*service"); // If i put "*Service" instead, then i get an exception. 
	    beanNameAutoProxyCreator.setInterceptorNames("systemTransactionInterceptor");
	    beanNameAutoProxyCreator.setProxyTargetClass(true);
	    return beanNameAutoProxyCreator;
	}
}
